package ort.domain;

import java.io.Serializable;

import ort.constants.Constants;

public class RoundScore implements Serializable{

	private double pointsBoxer1 = 0;
	private double pointsBoxer2 = 0;
	private int countsToBoxer1 = 0;
	private int countsToBoxer2 = 0;

	public double addScoreToBoxer1() {
		pointsBoxer1++;
		return pointsBoxer1;
	}

	public double addScoreToBoxer2() {
		pointsBoxer2++;
		return pointsBoxer2;
	}

	public int addCountToBoxer1() {
		countsToBoxer1++;
		return countsToBoxer1;
		
	}

	public int addCountToBoxer2() {
		countsToBoxer2++;
		return countsToBoxer2;
	}

	public double getScoreBoxer1() {
		return pointsBoxer1;
	}

	public double getScoreBoxer2() {
		return pointsBoxer2;
	}

	public void closeRoundScore() {

		double diffBox1ToBox2 = pointsBoxer1 - pointsBoxer2;

		if (diffBox1ToBox2 > 0) {

			// Gano el Boxeador 1
			pointsBoxer1 = Constants.WINNER_ROUND_POINTS;

			if (diffBox1ToBox2 <= 1) {
				pointsBoxer2 = Constants.LITTLE_WINNER_ROUND_POINTS;
			} else {
				pointsBoxer2 = Constants.LOSER_ROUND_POINTS;
			}

		} else if (diffBox1ToBox2 < 0) {

			// Gano el Boxeador 2
			diffBox1ToBox2 = Math.abs(diffBox1ToBox2);
			pointsBoxer2 = Constants.WINNER_ROUND_POINTS;

			if (diffBox1ToBox2 <= 1) {
				pointsBoxer1 = Constants.LITTLE_WINNER_ROUND_POINTS;
			} else {
				pointsBoxer1 = Constants.LOSER_ROUND_POINTS;
			}
		} else{
			// Empate
			pointsBoxer1 = Constants.DRAW_ROUND_POINTS;
			pointsBoxer2 = Constants.DRAW_ROUND_POINTS;
			
		}
		
		// Al final resto el punto de los incidentes
		pointsBoxer1 -= countsToBoxer1;
		pointsBoxer2 -= countsToBoxer2;
		

	}
	
	@Override
	public String toString() {
		return "BOXEADOR 1: " + pointsBoxer1 + "\n" + "BOXEADOR 2: " + pointsBoxer2;
	}

}
